import request from '../../utils/request'
import {requestString} from '../../utils/request'

/**
 * 分页获取收票列表
 * @param orderno
 * @param userIds
 * @param openinvoicestatus
 * @param page
 * @returns {Promise.<void>}
 */
export async function getRecinvoicesList({contractno, openinvoicestatus, page}) {

    return request(apiPath.mc + "/api/tax/recinvoices", {
        method: 'get',
        data: {contractno, openinvoicestatus, page: page.page, size: page.size}
    });
}


/**
 * 发票审核
 * @param orderId
 * @param approvalresult
 * @param businesstype
 * @param entityid
 * @param approvalmemo
 * @returns {Promise.<void>}
 */
export async function approval({orderId, approvalresult, businesstype, entityid, approvalmemo}) {
    businesstype = "invoice";
    return request(apiPath.mc + "/api/tax/approval", {
        method: 'post',
        data: {orderId, approvalresult, businesstype, entityid, approvalmemo}
    });
}

/**
 * 认证发票
 * @param checkStatus
 * @param memo
 * @param orderId
 * @returns {Promise.<void>}
 */
export async function checkinvoice({checkStatus, memo, orderId, checkinvoicetime}) {
    return request(apiPath.mc + "/api/tax/checkinvoice", {
        method: 'put',
        data: {checkStatus, memo, orderId, checkinvoicetime}
    });
}

const Ajax = require('robe-ajax');
/**
 * 收票
 * @param orderId
 * @param taxInvoiceForms
 * @returns {Promise.<void>}
 */
export async function receiveinvoice({form }) {

    return requestString(apiPath.mc + "/api/tax/receiveinvoice", {
        method: 'POST',
        data: {...form}
    });


}

/**
 * 批量认证发票
 * @param checkStatus
 * @param memo
 * @param orderId
 * @returns {Promise.<void>}
 */
export async function batchCheckinvoice({ ids }) {
    return requestString(apiPath.mc + "/api/tax/batch/checkinvoice", {
        method: 'put',
        data: ids
    });
}